/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package networkrespnse;

import utils.Utils;

/**
 *
 * @author Kvest
 */
public class SrvMessageResponse extends Response
{
    private String message;
    
    public SrvMessageResponse(byte[] data)
    {
        super(SRV_MESSAGE_RESPONSE);
        message = "";
        
        parse(data);
    }

    protected void parse(byte[] data)
    {
        byte[] temp;
        int size,index;

        index = 0;
        temp = new byte[4];
        //������������� ��������
        for (int i=0;i<4;i++)
        {
                temp[i] = data[index++];
        }
        index += Utils.byteToInt(temp);

        //�������� Message
        for (int i=0;i<4;i++)
        {
                temp[i] = data[index++];
        }
        size = Utils.byteToInt(temp);
        temp = new byte[size];
        for (int i=0;i<size;i++)
        {
                temp[i] = data[index++];
        }
        message = Utils.byteToString(temp);

	System.gc();
    }

    public String getMessage()
    {
        return message;
    }
}
